package com.leoman.dao;

import com.leoman.entity.VideoResume;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 简历投递记录
 * Created by Administrator on 2016/10/18 0018 下午 3:07.
 */
public interface VideoResumeDao extends JpaRepository<VideoResume, Integer>, JpaSpecificationExecutor<VideoResume> {

    @Query("select a from VideoResume a where a.userResume.appUser.id = ?1 and a.videoRecord.id = ?2")
    VideoResume iFindOneByUserIdAndVideoRecordId(Integer userId, Integer videoRecordId);

    @Query("select a from VideoResume a where a.userResume.appUser.id = ?1 order by a.id desc")
    Page<VideoResume> iPageByUserId(Integer userId, Pageable pageable);

    @Query("select a from VideoResume a where a.videoRecord.video.companyUser.id = ?1 order by a.id desc")
    Page<VideoResume> iPageByCompanyUserId(Integer companyUserId, Pageable pageable);

    @Query("select a from VideoResume a where a.videoRecord.video.id = ?1")
    List<VideoResume> iFindListByVideoId(Integer videoId);

    @Query("select a from VideoResume a where a.videoRecord.id = ?1")
    List<VideoResume> iFindListByVideoRecordId(Integer videoRecordId);
}